﻿using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace OneRed.Main.Comm
{
    public class DaoHang
    {
        /// <summary>
        /// 将新页内容替换旧页内容在主窗体中
        /// </summary>
        /// <param name="MainPG">主窗体中的旧页</param>
        /// <param name="NewPG">新要添加的页</param>
        /// <returns></returns>
        public static void GetMainWindowFrame(Page MainPG, object NewPG, string Part = "body")
        {
            (MetroWindow.GetWindow(MainPG).FindName(Part) as Frame).Content = NewPG;
        }

        /// <summary>
        /// 获取当前页所在的主窗体
        /// </summary>
        /// <param name="MainPG">主窗体中的旧页</param>
        /// <returns></returns>
        public static Window GetMainWindowFrame(Page MainPG)
        {
            return MetroWindow.GetWindow(MainPG);
            //WindowBase.GetWindow(MainPG).fr
        }
    }

}